package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.BMIDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {
    @RequestMapping("/bmi")
    @ResponseBody
    public String getBMI(double weight, double height){
        double bmi = weight / (height * height);
        if(bmi < 18.5){
            return "偏瘦";
        }else if(bmi < 24){
            return "正常";
        }else if(bmi < 27){
            return "微胖";
        }else{
            return "该减肥了";
        }
    }

    @RequestMapping("/bmi2")
    @ResponseBody
    public String getBMI2(BMIDTO bmiDTO){
        double bmi = bmiDTO.getWeight() / (bmiDTO.getHeight() * bmiDTO.getHeight());
        if(bmi < 18.5){
            return "偏瘦2";
        }else if(bmi < 24){
            return "正常2";
        }else if(bmi < 27){
            return "微胖2";
        }else{
            return "该减肥了2";
        }
    }
}
